﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class PopWin_authorityacross : System.Web.UI.Page
{
    PM.PMSys.authority allauth = new PM.PMSys.authority();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //绑定DDL
            PM.Code.Web.controlbind.BindDropDownList(this.ddlRoles, "select typename,id from Sys_UserType", "typename", "id");
            this.ddlRoles.SelectedIndex = 0;
            //不要改table的名称因为改了table的名称后得重新写脚本
            auth.InnerHtml = allauth.CreateAuthorityTable("1");
            this.authvalues.Value = allauth.getCurrentAuth(Int32.Parse(this.ddlRoles.SelectedValue.Trim()));
        }
    }
    protected void ddlRoles_SelectedIndexChanged(object sender, EventArgs e)
    {
        auth.InnerHtml = allauth.CreateAuthorityTable("1");
        this.authvalues.Value = allauth.getCurrentAuth(Int32.Parse(this.ddlRoles.SelectedValue.Trim()));
    }
    protected void Submit_Authority(object sender, EventArgs e)
    {
        if (this.authvalues.Value.Trim() == string.Empty)
        {
            PM.Code.Web.alertmessage.ShowMsg(this.UpdatePanel1,"不允许有空权限角色！");
            return;
        }
        int result = allauth.Update_Authority_Across(this.authvalues.Value,Int32.Parse(this.ddlRoles.SelectedValue.Trim()));
        if (result > 0)
        {
            PM.Code.Web.alertmessage.ShowMsg(this.UpdatePanel1, "角色的越权设置成功！");
            this.SubmitAuth.Disabled = true;
        }
    }
}
